home *** CD-ROM | disk | FTP | other *** search
/ 3D Game Programming All in One / 3D Game Programming All in One Disc.iso / 3D2E / RESOURCES / CH6 / EMAGA6 / control / client / misc / messagebox.cs < prev    next >
Text File  |  2006-09-17  |  6KB  |  51 lines

  1. function MessageBox::Open(%this)                                                                           
  2. {                                                                                                          
  3.    %offset = 6;                                                                                            
  4.    if(%this.isVisible())                                                                                   
  5.       return;                                                                                              
  6.    %windowPos = "8 " @ ( getWord( outerChatFrame.position, 1 ) + getWord( outerChatFrame.extent, 1 ) + 1 );
  7.    %windowExt = getWord( OuterChatFrame.extent, 0 ) @ " " @ getWord( MessageBox_Frame.extent, 1 );         
  8.    %textExtent = getWord(MessageBox_Text.extent, 0);                                                       
  9.    %ctrlExtent = getWord(MessageBox_Frame.extent, 0);                                                      
  10.    Canvas.pushDialog(%this);                                                                               
  11.    MessageBox_Frame.position = %windowPos;                                                                 
  12.    MessageBox_Frame.extent = %windowExt;                                                                   
  13.    MessageBox_Edit.position = setWord(MessageBox_Edit.position, 0, %textExtent + %offset);                 
  14.    MessageBox_Edit.extent = setWord(MessageBox_Edit.extent, 0, %ctrlExtent - %textExtent - (2 * %offset)); 
  15.    %this.setVisible(true);                                                                                 
  16.    deactivateKeyboard();                                                                                   
  17.    MessageBox_Edit.makeFirstResponder(true);                                                               
  18. }                                                                                                          
  19. function MessageBox::Close(%this)                                                                          
  20. {                                                                                                          
  21.    if(!%this.isVisible())                                                                                  
  22.       return;                                                                                              
  23.    Canvas.popDialog(%this);                                                                                
  24.    %this.setVisible(false);                                                                                
  25.    if ( $enableDirectInput )                                                                               
  26.       activateKeyboard();                                                                                  
  27.    MessageBox_Edit.setValue("");                                                                           
  28. }                                                                                                          
  29. function MessageBox::ToggleState(%this)                                                                    
  30. {                                                                                                          
  31.    if(%this.isVisible())                                                                                   
  32.       %this.close();                                                                                       
  33.    else                                                                                                    
  34.       %this.open();                                                                                        
  35. }                                                                                                          
  36. function MessageBox_Edit::OnEscape(%this)                                                                  
  37. {                                                                                                          
  38.    MessageBox.close();                                                                                     
  39. }                                                                                                          
  40. function MessageBox_Edit::Eval(%this)                                                                      
  41. {                                                                                                          
  42.    %text = trim(%this.getValue());                                                                         
  43.    if(%text !$= "")                                                                                        
  44.       commandToServer('TypedMessage', %text);                                                              
  45.    MessageBox.close();                                                                                     
  46. }                                                                                                          
  47. function ToggleMessageBox(%make)                                                                           
  48. {                                                                                                          
  49.    if(%make)                                                                                               
  50.       MessageBox.toggleState();                                                                            
  51. }